/*!
 * Javascript for golbal.js, based on jquery.
 * @author zeyi ren
 * @date 2016-3-22
 * @update 2016-3-25
 *
 * @目录
 *    1. 页面头部背景高度拉伸js控制
 *    2. tab切换
 *    3. 控制照片 
 *    4. 返回顶部按钮
 */
 
 
/*divWidth 标签背景图宽  divHeight 标签背景图高  objclass 标签选择器名称*/
   function  automaticHeight(divWidth,divHeight,objClass){
		var screenwidth=$(window).width();
		var screenheights=$(window).height();
		var ratio=divWidth/divHeight;
		var bgheight=screenwidth/ratio;
		$("."+objClass).height(bgheight);	 
   }

	function tabs(tab_sub,con_sub,classname){
		$(con_sub+":first").show();
          var tablength = $(tab_sub).size(); 
      //  $(document).on("click", tab_sub, function () {
		  $(tab_sub).click(function(){
          var index = $(tab_sub).index(this);
          $(tab_sub).removeClass(classname).eq(index).addClass(classname);
          $(con_sub).hide().stop(false, false).eq(index).fadeIn();
        })
	
	}
	/*divheight 标签背景图高度  screenheight 屏幕高度  objclass 标签选择器名称*/
	function getDeviceHeight(divheight,screenheight,objclass){
		var screenwidth=$(window).width();
		var screenheights=$(window).height();
		var  ratio=divheight/screenheight;
		var divcurrentheight=screenheights*ratio;
		$(objclass).height(divcurrentheight);	
	
    }
	
	function returnTop(){
	    $(".top").click(function(){
			$("html, body").animate({
				"scroll-top":0
			},"fast");
		});
		$(window).scroll(function(){//bug
		var _top=$(window).scrollTop();
		var _screenHeight=$(window).height();
		if(_top>100){
			$(".top").show();
		}else{
			$(".top").hide();
		}
		/*if(_top>200){
			$(".search_top").css({"background-color":"#f32d2d","opacity":"2"});
		}else{
			$(".search_top").css("background","-webkit-linear-gradient(top,rgba(0,0,0,.7),rgba(0,0,0,0))");
		}*/
	   });	
	}
	
$(function(){
  returnTop();
})